package com.xy.protobuf;

import java.io.ByteArrayOutputStream;
import java.io.IOException;

public class Main {
    public static void main(String[] args) throws IOException {
        UserInfo.UserMsg.Builder builder = UserInfo.UserMsg.newBuilder();
        builder.setId(1);
        builder.setAge(11);
        builder.setStatus(1);
        builder.setName("tom");
        UserInfo.UserMsg msg = builder.build();
        ByteArrayOutputStream output = new ByteArrayOutputStream();
        msg.writeTo(output);
        byte[] byteArray = output.toByteArray();
        UserInfo.UserMsg msg1 = UserInfo.UserMsg.parseFrom(byteArray);
        System.out.println(msg1);
    }
}
